<!-- Faraday Penetration Test IDE -->
<!-- Copyright (C) 2017  Infobyte LLC (http://www.infobytesec.com/) -->
<!-- See the file 'doc/LICENSE' for the license information -->

<section id="main" class="seccion clearfix">
    <div class="faraday-header-border-fix"></div>
    <div class="right-main">
        <div ng-controller="headerCtrl" ng-include="'scripts/commons/partials/header.html'"></div>
        <div id="reports-main" class="fila clearfix">

          <div class="reports col-md-12 col-sm-12 col-xs-12">
              <div class="button-control justify-flex-start  col-md-12 col-sm-12 col-xs-12">
                  
                  <div class="control-wrapper control-new">
                      <button id="new" type="button" class="btn btn-success btn-new" ng-title="{{workspaceData.readonly == false? 'New credential' : 'Read-only. Workspace disabled'}}" ng-if="parentObject.parent_type" ng-click="new()" ng-disabled="workspaceData.readonly == true">
                          New
                      </button>
                  </div>
                  <div class="control-wrapper control-edit">
                      <button type="button" class="btn edit" title="{{workspaceData.readonly == false ? 'Edit selected credentials' : 'Read-only. Workspace disabled'}}" ng-disabled="selectedCredentials().length != 1 || workspaceData.readonly == true" ng-click="edit()">
                          <img src="images/icon-toolbar-edit.svg" class="edit-icon" />
                      </button>
                  </div>
                  <div class="control-wrapper">
                      <button  id="delete" type="button" class="btn" title="{{workspaceData.readonly == false ? 'Delete selected credentials' : 'Read-only. Workspace disabled'}}" ng-disabled="selectedCredentials().length == 0 || workspaceData.readonly == true" ng-click="delete()">
                          <img src="images/icon-toolbar-delete.svg" class="delete-icon" />
                      </button>
                  </div>
                  <div class="control-wrapper search-wrapper">
                      <form role="form">
                          <div class="form-group">
                              <div class="input-group">
                                  <span class="input-group-addon glyphicon-btn glyphicon glyphicon-remove" ng-if="search && search != 'confirmed=true'" style="cursor: pointer" ng-click="clearSearch()"></span>
                                  <input type="text" class="form-control" placeholder="Enter keywords" ng-model="search" />
                                  <span class="input-group-addon glyphicon-btn">
                                      <img src="images/icon-toolbar-searchbar-loupe.svg" class="search-icon" />
                                  </span>
                              </div>
                          </div>
                      </form>
                  </div>
              </div>
            </div>
        </div>
            <div class="reports col-md-12 col-sm-12 col-xs-12">
                <table ng-if="credentials.length > 0" class="table-v3 licenses-list table table-responsive">
                    <thead>
                        <tr class="ui-grid-header">
                            <th class="ui-grid-cell-contents checkbox-select ui-grid-header-cell">
                                <input type="checkbox" ng-model="selectall" ng-click="checkAll()"/>
                            </th>
                            <th ng-if="!parentObject.parent_type" class="ui-grid-cell-contents ui-grid-header-cell">
                                <span ng-click="toggleSort('target')">Target</span>
                            </th>
                            <th class="ui-grid-cell-contents ui-grid-header-cell">
                                <span ng-click="toggleSort('name')">Name</span>
                            </th>
                            <th class="ui-grid-cell-contents ui-grid-header-cell">
                                <span ng-click="toggleSort('username')">Username</span>
                            </th>
                            <th class="ui-grid-cell-contents ui-grid-header-cell">
                                <span ng-click="toggleSort('password')">Password</span>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="credential in credentials | filter:search | orderBy:sort_field:reverse"
                            selection-model selection-model-type="checkbox"
                            selection-model-mode="multiple-additive"
                            selection-model-selected-class="multi-selected"
                            selection-model-on-change="selectedCredentials()">
                            <td class="ui-grid-cell-contents checkbox-select">
                                <input type="checkbox" name="{{credential._id}}"/>
                            </td>
                            <td class="ui-grid-cell-contents" ng-if="!parentObject.parent_type"> {{credential.target}} </td>
                            <td class="ui-grid-cell-contents">{{credential.name}}</td>
                            <td class="ui-grid-cell-contents">{{credential.username}}</td>
                            <td class="ui-grid-cell-contents">{{credential.password}}</td>
                        </tr>
                    </tbody>
                </table>
                <h3 ng-if="credentials.length == 0">
                    No credentials found in this workspace
                </h3>
            </div>
        </div>
    </div>
</section>
